package com.shr.code_interview;

public class Solution_3 {
    public boolean duplicate(int numbers[],int length,int [] duplication) {
    	for(int i = 0;i<length;i++){
    		while(numbers[i] != i){
    			if(numbers[i] == numbers[numbers[i]]){
    				duplication[0] = numbers[i] ;
    				return true;
    			}
    			swap(numbers, i, numbers[i]) ;
    		}
    	}
    	return false ;
    }

	private void swap(int[] numbers, int i, int j) {
		int temp = numbers[i] ;
		numbers[i] = numbers[j] ;
		numbers[j] = temp ;
		
	}

}
